<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<link rel="stylesheet" type="text/css" href="../Res/Bootstrap/css/bootstrap.min.css">
<script src="http://libs.baidu.com/jquery/1.4.2/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="../Res/Css/empheader.css">
<style>
#sign {
	width:90px;
}
</style>

<script type="text/javascript">
	$(document).ready(function(){
		$.ajax({
			type:"post",
			url:"../Sign",
			data:{sign:"empty"},
			success:function(data,textStatus){
				//alert(data);
				if(data==1){
					$("#sign").text("Sign out");
					$("#sign").removeClass("btn btn-info btn-success");
					$("#sign").addClass("btn btn-success");
				}else if(data==0){
					$("#sign").text("Sign in");
					$("#sign").removeClass("btn btn-info btn-success");
					$("#sign").addClass("btn btn-info");
				}else if(data==2){
					//alert("111");
					$("#sign").removeClass("btn btn-info btn-success");
					$("#sign").text("Signed");
					$("#sign").addClass("btn btn-default");
					$("#sign").attr("disabled","disabled");
				}
			}
		});
		$("#sign").click(function(){
			var flag;
			if($(this).text()=="Sign in"){
				flag="sign_in";
			}else{
				flag="sign_out";
			}
			$.ajax({
				type:"post",
				url:"../Sign",
				data:{sign:flag},
				success:function(data,textStatus){
					//alert(data);
					if(data==3){
						$("#sign").text("Sign out");
						$("#sign").removeClass("btn btn-info btn-success");
						$("#sign").addClass("btn btn-info");
					}else if(data==4){
						$("#sign").removeClass("btn btn-info btn-success");
						$("#sign").text("Signed");
						$("#sign").addClass("btn btn-default");
						$("#sign").attr("disabled","disabled");
					}
				}  
			});
		});
	});
</script>
<div class="container bg">
	<div id="uname">
		 Welcome &nbsp;${sessionScope.username} 
		 <a style="color:white" class="btn bg-danger btn-link" href="../logout.jsp" target="_top">Logout</a>
		 <br/>
		<button id="sign">Sign in</button>&nbsp;&nbsp;
		 <c:if test="${sessionScope.role == 'admin'}">						<%-- 如果是admin,则显示manager登陆按钮，否则不显示 --%>
		 	<a href="../hr.jsp" target="_top"><button class="btn btn-info">HR manager</button></a>
		 </c:if>
	 </div>
</div>
